﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LLKanWebService.BLL;
using LLKanWebService.Model;
public partial class settlement : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["account"] != null)
            {
                if (Request["action"] != null)
                {
                    UserManager usm = new UserManager();
                    ScoreManager scm = new ScoreManager();
                    Users user = usm.findUserByAccount(Session["account"].ToString());
                    if (Request["action"].ToString() == "begin")
                    {
                        usm.changeBenvolence(user.ID);
                    }
                    else if (Request["action"].ToString() == "end")
                    {
                        if (Request["playScore"] != null && Request["money"] != null && Request["experience"] != null)
                        {
                            int playScore = Int32.Parse(Request["playScore"].ToString());
                            int money = Int32.Parse(Request["money"].ToString());
                            int experience = Int32.Parse(Request["experience"].ToString());


                            scm.changeScore(user.ID, playScore);
                            user.Money += money;
                            user.Experience += experience;
                            usm.settlement(user);
                        }
                    }
                }

            }
        }
    }
}